package com.zx.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zx.bean.Bill;
import com.zx.dao.BillMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author CaesarChang张旭
 * @Date 2020/11/10  7:40 下午
 * @Version 1.0
 */
@Service
public class BillService {
    @Autowired
    private BillMapper billMapper;

    public List<Bill> list(Bill b) {
        return billMapper.select(b);
    }

    public int add(Bill b) {
        return billMapper.insert(b);
    }

    public Bill get(Long id) {
        return billMapper.selectByPrimaryKey(id);
    }

    public int update(Bill b) {
        return billMapper.updateByPrimaryKey(b);
    }

    public int delete(Long id) {
        return billMapper.deleteByPrimaryKey(id);
    }
    public PageInfo<Bill> listPage(Bill b,int pageNum,int pageSize){
        return PageHelper.startPage(pageNum,pageSize).doSelectPageInfo(()->{
            billMapper.select(b);
        });
    }
}